package com.cheng.project_model1.constract;

import lombok.Builder;
import lombok.Data;

/**
 * @author emiyakiri
 */
@Data
@Builder
public class JsonResult {
    private int code;
    private String msg;
    private Object data;

    public JsonResult() {
        this.code = ResponseCode.SUCCESS;
    }

    public JsonResult(Object data) {
        this.code = data instanceof Exception ? ResponseCode.FAILURE : ResponseCode.SUCCESS;
        this.data = data;
    }

    public JsonResult(int code, Object data) {
        this.code = code;
        this.data = data;
    }

    public JsonResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public JsonResult(String msg, Object data) {
        this.code = data instanceof Exception ? ResponseCode.SUCCESS : ResponseCode.SUCCESS;
        this.msg = msg;
        this.data = data;
    }

    public JsonResult(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

}
